using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
using System.Web;
using System.Threading;

namespace Data
{
	/// <summary>
	/// Strongly-typed collection for the articlecategory class.
	/// </summary>
	[Serializable]
	public partial class articlecategoryCollection : ActiveList<articlecategory, articlecategoryCollection> 
	{	   
		public articlecategoryCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the articlecategory table.
	/// </summary>
	[Serializable]
	public partial class articlecategory : ActiveRecord<articlecategory>
	{
		#region .ctors and Default Settings
		
		public articlecategory()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public articlecategory(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

		public articlecategory(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public articlecategory(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor
		public static Query CreateQuery() { return new Query(Schema); }

		
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("articlecategory", TableType.Table, DataService.GetInstance("MyProvider"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"";
				//columns
				
				TableSchema.TableColumn colvarArtCateID = new TableSchema.TableColumn(schema);
				colvarArtCateID.ColumnName = "ArtCateID";
				colvarArtCateID.DataType = DbType.String;
				colvarArtCateID.MaxLength = 40;
				colvarArtCateID.AutoIncrement = false;
				colvarArtCateID.IsNullable = false;
				colvarArtCateID.IsPrimaryKey = true;
				colvarArtCateID.IsForeignKey = false;
				colvarArtCateID.IsReadOnly = false;
				colvarArtCateID.DefaultSetting = @"";
				colvarArtCateID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarArtCateID);
				
				TableSchema.TableColumn colvarCateName = new TableSchema.TableColumn(schema);
				colvarCateName.ColumnName = "CateName";
				colvarCateName.DataType = DbType.String;
				colvarCateName.MaxLength = 255;
				colvarCateName.AutoIncrement = false;
				colvarCateName.IsNullable = true;
				colvarCateName.IsPrimaryKey = false;
				colvarCateName.IsForeignKey = false;
				colvarCateName.IsReadOnly = false;
				colvarCateName.DefaultSetting = @"";
				colvarCateName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCateName);
				
				TableSchema.TableColumn colvarDescription = new TableSchema.TableColumn(schema);
				colvarDescription.ColumnName = "Description";
				colvarDescription.DataType = DbType.String;
				colvarDescription.MaxLength = 500;
				colvarDescription.AutoIncrement = false;
				colvarDescription.IsNullable = true;
				colvarDescription.IsPrimaryKey = false;
				colvarDescription.IsForeignKey = false;
				colvarDescription.IsReadOnly = false;
				colvarDescription.DefaultSetting = @"";
				colvarDescription.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDescription);
				
				TableSchema.TableColumn colvarCateParent = new TableSchema.TableColumn(schema);
				colvarCateParent.ColumnName = "CateParent";
				colvarCateParent.DataType = DbType.String;
				colvarCateParent.MaxLength = 500;
				colvarCateParent.AutoIncrement = false;
				colvarCateParent.IsNullable = true;
				colvarCateParent.IsPrimaryKey = false;
				colvarCateParent.IsForeignKey = false;
				colvarCateParent.IsReadOnly = false;
				colvarCateParent.DefaultSetting = @"";
				colvarCateParent.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCateParent);
				
				TableSchema.TableColumn colvarVipLevel = new TableSchema.TableColumn(schema);
				colvarVipLevel.ColumnName = "VipLevel";
				colvarVipLevel.DataType = DbType.Int32;
				colvarVipLevel.MaxLength = 11;
				colvarVipLevel.AutoIncrement = false;
				colvarVipLevel.IsNullable = true;
				colvarVipLevel.IsPrimaryKey = false;
				colvarVipLevel.IsForeignKey = false;
				colvarVipLevel.IsReadOnly = false;
				colvarVipLevel.DefaultSetting = @"";
				colvarVipLevel.ForeignKeyTableName = "";
				schema.Columns.Add(colvarVipLevel);
				
				TableSchema.TableColumn colvarActive = new TableSchema.TableColumn(schema);
				colvarActive.ColumnName = "Active";
				colvarActive.DataType = DbType.Boolean;
				colvarActive.MaxLength = 1;
				colvarActive.AutoIncrement = false;
				colvarActive.IsNullable = true;
				colvarActive.IsPrimaryKey = false;
				colvarActive.IsForeignKey = false;
				colvarActive.IsReadOnly = false;
				colvarActive.DefaultSetting = @"";
				colvarActive.ForeignKeyTableName = "";
				schema.Columns.Add(colvarActive);
				
				TableSchema.TableColumn colvarCreatedDate = new TableSchema.TableColumn(schema);
				colvarCreatedDate.ColumnName = "CreatedDate";
				colvarCreatedDate.DataType = DbType.DateTime;
				colvarCreatedDate.MaxLength = 0;
				colvarCreatedDate.AutoIncrement = false;
				colvarCreatedDate.IsNullable = true;
				colvarCreatedDate.IsPrimaryKey = false;
				colvarCreatedDate.IsForeignKey = false;
				colvarCreatedDate.IsReadOnly = false;
				colvarCreatedDate.DefaultSetting = @"";
				colvarCreatedDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedDate);
				
				TableSchema.TableColumn colvarUpdatedDate = new TableSchema.TableColumn(schema);
				colvarUpdatedDate.ColumnName = "UpdatedDate";
				colvarUpdatedDate.DataType = DbType.DateTime;
				colvarUpdatedDate.MaxLength = 0;
				colvarUpdatedDate.AutoIncrement = false;
				colvarUpdatedDate.IsNullable = true;
				colvarUpdatedDate.IsPrimaryKey = false;
				colvarUpdatedDate.IsForeignKey = false;
				colvarUpdatedDate.IsReadOnly = false;
				colvarUpdatedDate.DefaultSetting = @"";
				colvarUpdatedDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUpdatedDate);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["MyProvider"].AddSchema("articlecategory",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("ArtCateID")]
		public string ArtCateID 
		{
			get { return GetColumnValue<string>("ArtCateID"); }

			set { SetColumnValue("ArtCateID", value); }

		}

		  
		[XmlAttribute("CateName")]
		public string CateName 
		{
			get { return GetColumnValue<string>("CateName"); }

			set { SetColumnValue("CateName", value); }

		}

		  
		[XmlAttribute("Description")]
		public string Description 
		{
			get { return GetColumnValue<string>("Description"); }

			set { SetColumnValue("Description", value); }

		}

		  
		[XmlAttribute("CateParent")]
		public string CateParent 
		{
			get { return GetColumnValue<string>("CateParent"); }

			set { SetColumnValue("CateParent", value); }

		}

		  
		[XmlAttribute("VipLevel")]
		public int? VipLevel 
		{
			get { return GetColumnValue<int?>("VipLevel"); }

			set { SetColumnValue("VipLevel", value); }

		}

		  
		[XmlAttribute("Active")]
		public bool? Active 
		{
			get { return GetColumnValue<bool?>("Active"); }

			set { SetColumnValue("Active", value); }

		}

		  
		[XmlAttribute("CreatedDate")]
		public DateTime? CreatedDate 
		{
			get { return GetColumnValue<DateTime?>("CreatedDate"); }

			set { SetColumnValue("CreatedDate", value); }

		}

		  
		[XmlAttribute("UpdatedDate")]
		public DateTime? UpdatedDate 
		{
			get { return GetColumnValue<DateTime?>("UpdatedDate"); }

			set { SetColumnValue("UpdatedDate", value); }

		}

		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(string varArtCateID,string varCateName,string varDescription,string varCateParent,int? varVipLevel,bool? varActive,DateTime? varCreatedDate,DateTime? varUpdatedDate)
		{
			articlecategory item = new articlecategory();
			
			item.ArtCateID = varArtCateID;
			
			item.CateName = varCateName;
			
			item.Description = varDescription;
			
			item.CateParent = varCateParent;
			
			item.VipLevel = varVipLevel;
			
			item.Active = varActive;
			
			item.CreatedDate = varCreatedDate;
			
			item.UpdatedDate = varUpdatedDate;
			
		
			if (HttpContext.Current != null)
				item.Save(HttpContext.Current.User.Identity.Name);
			else
				item.Save(Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(string varArtCateID,string varCateName,string varDescription,string varCateParent,int? varVipLevel,bool? varActive,DateTime? varCreatedDate,DateTime? varUpdatedDate)
		{
			articlecategory item = new articlecategory();
			
				item.ArtCateID = varArtCateID;
				
				item.CateName = varCateName;
				
				item.Description = varDescription;
				
				item.CateParent = varCateParent;
				
				item.VipLevel = varVipLevel;
				
				item.Active = varActive;
				
				item.CreatedDate = varCreatedDate;
				
				item.UpdatedDate = varUpdatedDate;
				
			item.IsNew = false;
			if (HttpContext.Current != null)
				item.Save(HttpContext.Current.User.Identity.Name);
			else
				item.Save(Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
		#region Columns Struct
		public struct Columns
		{
			int i;
			 public static string ArtCateID = @"ArtCateID";
			 public static string CateName = @"CateName";
			 public static string Description = @"Description";
			 public static string CateParent = @"CateParent";
			 public static string VipLevel = @"VipLevel";
			 public static string Active = @"Active";
			 public static string CreatedDate = @"CreatedDate";
			 public static string UpdatedDate = @"UpdatedDate";
						
		}

		#endregion
	}

}

